home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / asm_msc1.arc / VMODE.ASM < prev    next >
Assembly Source File  |  1988-11-20  |  4KB  |  116 lines

  1. NAME VMODE
  2. TITLE 'VMODE---SET PC VIDEO MODE'
  3. ;
  4. ;RAY DUNCAN, SOFTTALK, JULY 83
  5. ;
  6. ;
  7. ;       Vmode 0   40 * 25 Black and White Text.
  8. ;         1   40 * 25 Color Text.
  9. ;         2   80 * 25 Black and White Text.
  10. ;         3   80 * 25 Color Text.
  11. ;
  12. ;         4   320 * 200 Color Graphics.
  13. ;         5   320 * 200 Black and White Graphics.
  14. ;         6   640 * 200 Black and White Graphics.
  15. ;         7   Monochrome monitor.
  16. ;
  17. ;Assembler invocation  A>ASM VMODE,VMODE,VMODE,VMODE
  18. ;Link invocation       A>LINK VMODE,VMODE,,,
  19. ;
  20. ;             *** The linker must be invoked with the 3 commas ***
  21. ;         You will get a LINKER ERROR  "missing STACK segment",
  22. ;         Just ignore it it is because this is a .COM file and must
  23. ;         conform to DOS requirements.
  24. ;
  25. ;Exe2bin invocation    A>EXE2BIN VMODE.EXE,VMODE.COM
  26. ;   and then.....      A>ERASE VMODE.EXE
  27. ;
  28. ;
  29. INPUT EQU 080H          ;Address of the command tail
  30.               ;buffer created by DOS
  31. BLANK EQU 020H          ;ASCII blank character
  32. CR    EQU 00DH          ;ASCII carriage return
  33. LF    EQU 00AH          ;ASCII line feed
  34. ;
  35. CSEG SEGMENT BYTE      ;Set up for a .COM file.
  36. ASSUME CS:CSEG,DS:CSEG      ;
  37. ORG   100H          ;
  38. ;
  39. VMODE:
  40. ;
  41. ;     These first 4 instructions detect invocation without command tail.
  42. ;
  43.    MOV    DI,OFFSET INPUT  ;Init DI to address of the INPUT buffer
  44.    MOV    AL,[DI]      ;move data pointed at by DI into AL
  45.    OR    AL,AL         ;check for missing command tail (0+0=0).
  46.    JZ    VMODE7         ;if there is no command tail VMODE7 will exit us.
  47. ;
  48. ;    Scan the Input buffer for a non-blank and check for valid mode#
  49. ;
  50.    MOV    AL,BLANK     ;Move ASCII blank into AL.
  51.    INC    DI         ;Increment DI one location in the INPUT buffer.
  52.    MOV    CX,80         ;Set the LOOP counter (CX) to 80. Max 80 char search.
  53.    CLD             ;Set the direction flag to 0, causing auto incr of DI.
  54.    REPZ SCASB         ;Repeat till CX=0, scan string (byte).
  55.    JZ    VMODE7         ;* If count down to zero means no match, so exit.
  56.    MOV    AL,-1[DI]     ;Move the byte in DI-1 since DI will incr one more.
  57.    CMP    AL,CR         ;Check for ASCII carriage return and
  58.    JZ    VMODE7         ; exit if it is.
  59.    CMP    AL,'0'           ;Check to see if it is less than ASCII 0 .
  60.    JB    VMODE8         ;Jump if below to VMODE8 (illegal mode #).
  61.    CMP    AL,'7'           ;Check for above ASCII 7.
  62.    JA    VMODE8         ;(illegal mode #)
  63.    MOV    VMODEB,AL     ;Its legal, save it in ASCII form for VMODEB to disp.
  64.    AND    AL,0FH         ;Mask upper four bits for true binary equivalent.
  65.    PUSH AX         ;Save numeric value on the stack.
  66. ;
  67. ;
  68. ;
  69.    XOR    BX,BX         ;Force BX to = 0, and use it to
  70.    MOV    ES,BX         ; set ES to 0
  71.    MOV    BX,410H      ;Set BX to = DOS' euipment flag word.
  72.    CMP    AL,7         ;* check for monochrome or color board.
  73.    MOV    AL,30H         ;Assume for now that it is monochrome.
  74.    JZ    VMODE6         ;It was monochrome, go set the mode.
  75.    MOV    AL,20H         ;Wrong! It was color. fall thru to set the mode.
  76. ;
  77. VMODE6:    ;Set the flags for new mode, calls video function 0,
  78. ;       and sets DX to point to start of success mesage.
  79. ;
  80.    AND BYTE PTR ES:[BX],0CFH  ;Merge in the right flag
  81.    OR  ES:[BX],AL     ;    for new selected mode.
  82.    POP AX         ;Get the mode # from the stack.
  83.    XOR AH,AH         ;Clear the high byte of AX.
  84.    INT 10H         ;BIOS CALL   see TECH REF pgs A-43, A-44.
  85.    MOV DX,OFFSET VMODEA  ;Set DX = to start of sucess string.
  86.    JMP SHORT VMODE9     ;VMODE9 uses DOS CALL 21H to display strings.
  87. ;
  88. VMODE7:
  89. ;
  90.    MOV DX,OFFSET VMODEC  ;Cause DX to point at "missing mode #" msg.
  91.    JMP SHORT VMODE9
  92. ;
  93. VMODE8:
  94. ;
  95.    MOV DX,OFFSET VMODED  ;Cause DX to point at "Illegal mode #" msg.
  96. ;
  97. VMODE9:
  98. ;
  99.    MOV AH,9         ; set AH for function 9 of
  100.    INT 21H         ; Start display at address in DX, $ = terminate.
  101.    INT 20H         ; Causes return to DOS.
  102. ;
  103. VMODEA DB CR,LF
  104.        DB 'VIDEO MODE SET TO...   '
  105. ;
  106. VMODEB DB ' ',CR,LF,'$' ; Note that Vmodeb terminates text from Vmodea.
  107. VMODEC DB CR,LF
  108.        DB 'MISSING MODE NUMBER.'
  109.        DB CR,LF,'$'
  110. VMODED DB CR,LF
  111.        DB 'ILLEGAL MODE NUMBER.'
  112.        DB CR,LF,'$'
  113. CSEG ENDS
  114. END VMODE
  115.  
  116.